package com.ruijie.autotest.log.core.validate;

import java.util.function.UnaryOperator;

public interface IValidator {
	boolean validate(String actualValue);

	default IValidator after(UnaryOperator<String> preprocessing) {
		return actualValue -> IValidator.this.validate(preprocessing.apply(actualValue));
	}

	default IValidator or(IValidator target) {
		return actualValue ->
				IValidator.this.validate(actualValue) || target.validate(actualValue);
	}

	static IValidator alwaysRight() {
		return actualValue -> true;
	}

	static IValidator alwaysWrong() {
		return actualValue -> false;
	}
}
